/**
 * 
 */
package trungsi.gea.photos.stripes;

import java.util.Collection;
import java.util.Locale;

import net.sourceforge.stripes.integration.spring.SpringBean;
import net.sourceforge.stripes.validation.TypeConverter;
import net.sourceforge.stripes.validation.ValidationError;
import trungsi.gea.photos.domain.Entity;
import trungsi.gea.photos.jdo.PersistenceManagerHolder;

/**
 * @author trungsi
 *
 */
public class EntityTypeConverter implements TypeConverter<Entity> {
	@SpringBean
	private PersistenceManagerHolder pmHolder;
	
	@Override
	public Entity convert(String id, Class<? extends Entity> klass,
			Collection<ValidationError> errors) {
		if (id != null) {
			return pmHolder.get().getObjectById(klass, id);
		}
		return null;
	}

	@Override
	public void setLocale(Locale arg0) {
		// TODO Auto-generated method stub
		
	}

}
